package com.ruoyi.teaching.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.teaching.domain.TeachingBooktitle;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.TeachingRecord;
import com.ruoyi.teaching.service.ITeachingRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学历信息Controller
 * 
 * @author ruoyi
 * @date 2022-03-21
 */
@RestController
@RequestMapping("/teaching/record")
public class TeachingRecordController extends BaseController
{
    @Autowired
    private ITeachingRecordService teachingRecordService;

    /**
     * 查询学历信息列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeachingRecord teachingRecord)
    {
        startPage();
        List<TeachingRecord> list = teachingRecordService.selectTeachingRecordList(teachingRecord);
        return getDataTable(list);
    }
    @GetMapping("/listAll")
    public AjaxResult getAll()
    {
        TeachingRecord teachingRecord = new TeachingRecord();
        List<TeachingRecord> list = teachingRecordService.selectTeachingRecordList(teachingRecord);
        return AjaxResult.success(list);
    }
    /**
     * 导出学历信息列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:record:export')")
    @Log(title = "学历信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeachingRecord teachingRecord)
    {
        List<TeachingRecord> list = teachingRecordService.selectTeachingRecordList(teachingRecord);
        ExcelUtil<TeachingRecord> util = new ExcelUtil<TeachingRecord>(TeachingRecord.class);
        util.exportExcel(response, list, "学历信息数据");
    }

    /**
     * 获取学历信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:record:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(teachingRecordService.selectTeachingRecordByRecordId(recordId));
    }

    /**
     * 新增学历信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:record:add')")
    @Log(title = "学历信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeachingRecord teachingRecord)
    {
        return toAjax(teachingRecordService.insertTeachingRecord(teachingRecord));
    }

    /**
     * 修改学历信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:record:edit')")
    @Log(title = "学历信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeachingRecord teachingRecord)
    {
        return toAjax(teachingRecordService.updateTeachingRecord(teachingRecord));
    }

    /**
     * 删除学历信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:record:remove')")
    @Log(title = "学历信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(teachingRecordService.deleteTeachingRecordByRecordIds(recordIds));
    }
}
